﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using WcfGeebaServer.Users;

namespace WcfGeebaServer.ContentManage
{
    [Serializable]
    public class GPost : GThread
    {
        #region Fields

        private GThread _parent;    // contains the topmost thread (one level below the subForum)

        #endregion

        #region DataMembers

        public GThread ParentThread
        {
            get
            {
                return this._parent;
            }
        }

        #endregion

        #region Ctors

        public GPost(int id, string subject, string content, Member publisher, GThread parent)
            : base(id, subject, content, publisher)
        {
            this._parent = parent;
        }

        public GPost(string subject, string content, Member publisher, GThread parent)
            : this(-1, subject, content, publisher, parent)
        {

        }

        public GPost(int id, GPost copy) : this(id, copy.Subject, copy.Content, copy.publishedBy, copy._parent)
        {
            this._publishDate = copy.PublishDate;
            this._modifiedDate = copy.ModifiedDate;
        }

         public GPost(int id, string subject, string content, Member publisher, GThread parent,DateTime publishDate,DateTime modifiedDate)
            : base(id, subject, content, publisher,publishDate,modifiedDate)
        {
            this._parent = parent;
        }
           
        #endregion

        #region Methods

        public override bool bump()
        {
            return base.bump() & _parent.bump();
        }

        public override bool Equals(Object obj)
        {
            if (obj == null)
            {
                return false;
            }

            GPost gp = obj as GPost;
            if ((Object)gp == null)
            {
                return false;
            }

            return base.Id == gp.Id;
        }

        public override int GetHashCode()
        {
            return this.Id;
        }

        #endregion
    }
}
